<template>
    <h3>id：{{user.id}} 姓名：{{ user.uname }} 年龄{{ user.age }}</h3>
    修改年龄：<input type="text" v-model="chageAge" @keydown.enter="chageAgeMe"><br>
    <button @click="leave(user.uname)">我要请假</button><br>
</template>

<script>
// npm i pubsub-js -S
import pubsub from 'pubsub-js'
export default {
    name:'User',
    props:['user'],
    data(){
        return{
            chageAge:''
        }
    },
    methods:{
        chageAgeMe(){
            this.user.age = this.chageAge;
        },
        leave(name){
            //去找对应的地方
            pubsub.publish('leave',name);
        }
    }
}
</script>

<style scoped>
/* scoped 局部样式 */

</style>